package io.renren.modules.health.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.renren.common.service.impl.CrudServiceImpl;
import io.renren.modules.health.dao.FoodPrePlanDetailDao;
import io.renren.modules.health.dto.FoodPrePlanDetailDTO;
import io.renren.modules.health.entity.FoodPrePlanDetailEntity;
import io.renren.modules.health.service.FoodPrePlanDetailService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * 计划详情
 *
 * @author Mark 
 * @since 1.0.0 2024-04-01
 */
@Service
public class FoodPrePlanDetailServiceImpl extends CrudServiceImpl<FoodPrePlanDetailDao, FoodPrePlanDetailEntity, FoodPrePlanDetailDTO> implements FoodPrePlanDetailService {

    @Override
    public QueryWrapper<FoodPrePlanDetailEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        List<Long> ids = (List<Long>)params.get("ids");
        List<Long> foodPrePlanIds = (List<Long>)params.get("foodPrePlanIds");
        Long foodPrePlanId = (Long) params.get("foodPrePlanId");

        QueryWrapper<FoodPrePlanDetailEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
        wrapper.in(ids != null && !ids.isEmpty(), "id", ids);
        wrapper.in(foodPrePlanIds != null && !foodPrePlanIds.isEmpty(), "food_pre_plan_id", foodPrePlanIds);
        wrapper.eq(!Objects.isNull(foodPrePlanId), "food_pre_plan_id", foodPrePlanId);

        return wrapper;
    }





}